package com.qf.utils;

import cn.hutool.core.io.file.FileAppender;
import cn.hutool.core.io.file.FileWriter;
import com.qf.entity.Book;

import java.io.File;
import java.util.List;

public class SetBooksUtils {
    private String filepath;

    public SetBooksUtils(String filepath) {
        this.filepath = filepath;
    }

    public  void setBooks(List<Book> books){
        FileWriter writer = new FileWriter(filepath);
        final FileAppender fileAppender = new FileAppender(new File(filepath),1000,true);
        for (Book book : books) {
            final String csv = book.toString();
            fileAppender.append(csv);

        }
        fileAppender.flush();
        
    }
}
